//
//  ApplyForOutHolidayViewController.m
//  AttendenceSys
//
//  Created by ld on 16/1/20.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ApplyForOutHolidayViewController.h"

@interface ApplyForOutHolidayViewController ()

@end

@implementation ApplyForOutHolidayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initView];
    // Do any additional setup after loading the view.
}

-(void)initView
{
    self.calendarView.defaultDays = _seletedDays;
    [self.calendarView show];
    
    //next
    
    UIButton* nextBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    nextBtn.frame = CGRectMake(50,self.view.frame.size.height/2+ 80,[UIScreen mainScreen].bounds.size.width-50*2,50);
    [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
    nextBtn.layer.cornerRadius = 4.5;
    [nextBtn addTarget:self action:@selector(nextBtn) forControlEvents:UIControlEventTouchUpInside];
    
    [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    nextBtn.backgroundColor = RGB(252, 120, 61);
    [self.view addSubview:nextBtn];
}

-(void)nextBtn
{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSString *)showStr {
    NSMutableString *str = [NSMutableString string];
    
    [str appendString:@"已选择日期:\r\n"];
    //从小到大排序
    [self.seletedDays sortUsingComparator:^NSComparisonResult(NSNumber *obj1, NSNumber *obj2) {
        return [obj1 compare:obj2];
    }];
    for (NSNumber *interval in self.seletedDays) {
        NSString *partStr = [NSDate stringWithTimestamp:interval.doubleValue format:@"MM.dd"];
        [str appendFormat:@"%@ ",partStr];
    }
    return str.copy;
}

- (ASCalendarView *)calendarView {
    if (!_calendarView) {
        _calendarView = [[ASCalendarView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height/2)];
        [self.view addSubview:_calendarView];
        
        __weak typeof(self) weakSelf = self;
        _calendarView.complete = ^(NSArray *result) {
            if (result) {
                weakSelf.seletedDays = result.mutableCopy;
            }
        };
    }
    return _calendarView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
